<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="stylesheet" th:href="@{../../lib/layui/css/layui.css}">
    <script charset="utf-8" th:src="@{../../lib/layui/layui.js}" type="text/javascript"></script>
    <!--    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>-->
    <script th:src="@{../../js/jquery-3.5.1.min.js}" type="text/javascript"></script>
    <style>
        .vintage{
            background: #EEE url() repeat;
            text-shadow: 5px -5px black, 4px -4px white;
            font-weight: bold;
            -webkit-text-fill-color: transparent;
            -webkit-background-clip: text }
    </style>
</head>
<body>
<div>
    <h1 th:class="vintage">宿舍楼宇后勤基础信息</h1>
</div>
<hr class="hr15"/>
<form class="layui-form" id="dbbiEditForm">
    <div class="layui-form-item">
        <label for="id" class="layui-form-label">楼宇编号</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" id="id" name="id" placeholder="请使用'0001000000XX'的格式"
                   readonly="readonly" type="text" style="border: 1px solid red">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="location" class="layui-form-label">校区</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" id="location" name="location" placeholder="草堂/雁塔"
                   readonly="readonly" type="text" style="border: 1px solid red">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="dormBuild" class="layui-form-label">宿舍楼宇</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" id="dormBuild" name="dormBuild" placeholder="请输入正确的楼宇名称"
                   readonly="readonly" type="text" style="border: 1px solid red">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="area" class="layui-form-label">占地面积</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" id="area" lay-verify="L_area" name="area"
                   placeholder="输入面积请保留0~3位小数" type="text" style="border: 1px solid green">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="buildTime" class="layui-form-label">建设时间</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" id="buildTime" name="buildTime" placeholder="只有年份"
                   readonly="readonly" type="text" style="border: 1px solid red">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="useTime" class="layui-form-label">投用时间</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" id="useTime" name="useTime" placeholder="只有年份"
                   readonly="readonly" type="text" style="border: 1px solid red">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="buildStru" class="layui-form-label">房屋结构</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" id="buildStru" name="buildStru"
                   placeholder="请输入正确的房屋结构" type="text" style="border: 1px solid green">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="roofArea" class="layui-form-label">屋面面积(㎡)</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" id="roofArea" lay-verify="L_roofArea" name="roofArea"
                   placeholder="输入面积请保留0~3位小数" type="text" style="border: 1px solid green">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="facadeMaterial" class="layui-form-label">外立面材质</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" id="facadeMaterial" name="facadeMaterial"
                   placeholder="请输入正确的外立面材质" type="text" style="border: 1px solid green">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="roomNum" class="layui-form-label">房间数(间)</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" id="roomNum" lay-verify="L_roomNum" name="roomNum"
                   placeholder="请输入房间个数" type="text" style="border: 1px solid green">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="dormStuNum" class="layui-form-label">住宿人数(人)</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" id="dormStuNum" lay-verify="L_dormStuNum" name="dormStuNum"
                   placeholder="请输入住宿人数" type="text" style="border: 1px solid green">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="switchBoxNum" class="layui-form-label">配电箱(个)</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" id="switchBoxNum" lay-verify="L_switchBoxNum"
                   name="switchBoxNum"
                   placeholder="请输入配电箱数" type="text" style="border: 1px solid green">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="toiletNum" class="layui-form-label">卫生间(间)</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" id="toiletNum" lay-verify="L_toiletNum" name="toiletNum"
                   placeholder="请输入卫生间数" type="text" style="border: 1px solid green">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="fireHydrantNum" class="layui-form-label">消防栓(个)</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" id="fireHydrantNum" lay-verify="L_fireHydrantNum"
                   name="fireHydrantNum"
                   placeholder="请输入消防栓数" type="text" style="border: 1px solid green">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="heatWellNum" class="layui-form-label">暖气井(个)</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" id="heatWellNum" lay-verify="L_heatWellNum" name="heatWellNum"
                   placeholder="请输入暖气井数" type="text" style="border: 1px solid green">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="elevatorNum" class="layui-form-label">电梯(部)</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" id="elevatorNum" lay-verify="L_elevatorNum" name="elevatorNum"
                   placeholder="请输入电梯数" type="text" style="border: 1px solid green">
        </div>
    </div>
    <hr class="hr15"/>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-filter="edit" lay-submit="" type="submit">编辑</button>
            <button class="layui-btn layui-btn-primary" type="reset">重置</button>
        </div>
    </div>
</form>

<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;

        var form = layui.form,
            layer = layui.layer;

        // 自定义验证
        form.verify({
            L_area: [/^(([1-9]{1}\d*)|(0{1}))(\.\d{0,3})?$/, '最多保留三位小数'],
            L_roofArea: [/^(([1-9]{1}\d*)|(0{1}))(\.\d{0,3})?$/, '最多请保留三位小数'],
            L_roomNum: [/^\d+$/, '请输入大于等于0的数字'],
            L_dormStuNum: [/^\d+$/, '请输入大于等于0的数字'],
            L_switchBoxNum: [/^\d+$/, '请输入大于等于0的数字'],
            L_toiletNum: [/^\d+$/, '请输入大于等于0的数字'],
            L_fireHydrantNum: [/^\d+$/, '请输入大于等于0的数字'],
            L_heatWellNum: [/^\d+$/, '请输入大于等于0的数字'],
            L_elevatorNum: [/^\d+$/, '请输入大于等于0的数字']
        });

        // 监听提交
        form.on('submit(edit)',
            function () {
                $.ajax({
                    url: "/dbbi_relax/edit",
                    data: $("#dbbiEditForm").serialize(),
                    type: "post",
                    dataType: "json",
                    success: function (data) {
                        if (data.code === 0) {
                            var index = parent.layer.getFrameIndex(window.name);
                            layer.msg(data.msg, {icon: 1, time: 1500, shade: 0.4}, function () {
                                parent.layer.close(index);
                            });
                        } else {
                            layer.msg(data.msg, {icon: 2, time: 1000, shade: 0.4});

                        }
                    }
                });
                return false;
            });

    });
</script>
</body>
</html>